﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DotNetUI.Controls
{
    /// <summary>
    /// 导航栏元素
    /// </summary>

    //[DefaultProperty("ExpandChildrens")]
    //[ContentProperty("ExpandChildrens")]
    [Localizability(LocalizationCategory.None, Readability = Readability.Unreadable)]
    [DefaultProperty(nameof(Items))]
    [ContentProperty(nameof(Items))]
    public class DotNetAzureNavBarGroup : RadioButton
    {
        static DotNetAzureNavBarGroup()
        {

            DefaultStyleKeyProperty.OverrideMetadata(typeof(DotNetAzureNavBarGroup), new FrameworkPropertyMetadata(typeof(DotNetAzureNavBarGroup)));
        }
        public static readonly DependencyProperty IconProperty = DependencyProperty.Register(nameof(Icon), typeof(ImageSource), typeof(DotNetAzureNavBarGroup));
        public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register(nameof(Caption), typeof(object), typeof(DotNetAzureNavBarGroup));
        public static readonly DependencyProperty StatusProperty = DependencyProperty.Register(nameof(Status), typeof(UIElement), typeof(DotNetAzureNavBarGroup));
        /// <summary>
        /// 图标
        /// </summary>
        public ImageSource Icon { get=>(ImageSource)this.GetValue(IconProperty); set=>SetValue(IconProperty,value); }
        /// <summary>
        /// 标题
        /// </summary>
        public object Caption { get => this.GetValue(CaptionProperty); set => SetValue(CaptionProperty, value); }
        /// <summary>
        /// 扩展元素
        /// </summary>
        public UIElement Status { get => (UIElement)this.GetValue(StatusProperty); set => SetValue(StatusProperty, value); }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            this.Template.FindName("childrens",this);
        }
        public ItemsControl ItemsControl { get; private set; } = new ItemsControl();
        public ItemCollection Items
        { 
            get=> ItemsControl.Items;
        } 
        public IEnumerable ItemsSource 
        {
            get => ItemsControl.ItemsSource;
            set => ItemsControl.ItemsSource = value;
        }
        /// <summary>
        /// 选择笔刷
        /// </summary>
        public static readonly DependencyProperty SelectBrushProperty = DependencyProperty.Register(nameof(SelectBrush), typeof(Brush), typeof(DotNetAzureNavBarGroup), new PropertyMetadata(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFA6A6A6"))));
        /// <summary>
        /// 选择笔刷
        /// </summary>
        public Brush SelectBrush { get => (Brush)this.GetValue(SelectBrushProperty); set => SetValue(SelectBrushProperty, value); }

        /// <summary>
        /// 是否选中
        /// </summary>
        public static readonly DependencyProperty IsSmallModeProperty = DependencyProperty.Register(nameof(IsSmallMode), typeof(bool), typeof(DotNetAzureNavBarGroup), new PropertyMetadata(false));
        /// <summary>
        /// 是否选中
        /// </summary>
        public bool IsSmallMode
        {
            get => this.GetValue<bool>(IsCheckedProperty);
            set => SetValue(IsCheckedProperty, value);
        }

    }
}
